//
//  ViewController.m
//  TEST
//
//  Created by huajun on 2017/6/20.
//  Copyright © 2017年 huajun. All rights reserved.
//

#import "ViewController.h"
#import "Networking.h"
#import "SingleCase.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *topView;
//背景圆环
@property (nonatomic, strong) CAShapeLayer *backCircle;
//前面圆环
@property (nonatomic, strong) CAShapeLayer *foreCircle;

@end





@implementation ViewController
- (IBAction)start:(id)sender {
    [Networking getDataWithApiName:@"domain.goods.findGoodsByIdToAPP" parameter:@{@"goodsId":@"2180011102331977259"} result:^(NSDictionary *dic) {
       NSLog(@"++++++%@",dic);
        
    } fail:^(NSError *error) {
       NSLog(@"------%@",error);
    }];
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
//    NSString *str = @"点单号：98741235你好";
//    NSScanner *scanner = [NSScanner scannerWithString:str];
//    [scanner scanUpToCharactersFromSet:[NSCharacterSet decimalDigitCharacterSet] intoString:nil];
//    int number;
//    [scanner scanInt:&number];
 
//    NSLog(@"number : %d", number);
//    NSString *string = @"efijwijioasj12312374";
//    string = [[string componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet]] componentsJoinedByString:@""];
//    NSLog(@"number : %@", string);
}
- (IBAction)go:(id)sender {

    
 
    
//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/us/app/%E5%93%86%E5%A4%87%E5%AE%9D/id1236427625?mt=8&uo=4"]];
    
}
- (NSString *)firstCharactorWithString:(NSString *)string
{
    
    
    NSMutableString *str = [NSMutableString stringWithString:string];
    
    CFStringTransform((CFMutableStringRef) str, NULL, kCFStringTransformMandarinLatin, NO);
    
    CFStringTransform((CFMutableStringRef)str, NULL, kCFStringTransformStripDiacritics, NO);
    
    NSString *pinYin = [str capitalizedString];
    
    return [pinYin substringToIndex:1];
    
}
- (UIColor *)colorWithHexString:(NSString *)color
{
    NSString *cString = [[color stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
    
    // String should be 6 or 8 characters
    if ([cString length] < 6) {
        return [UIColor clearColor];
    }
    
    // strip 0X if it appears
    if ([cString hasPrefix:@"0X"])
        cString = [cString substringFromIndex:2];
    if ([cString hasPrefix:@"#"])
        cString = [cString substringFromIndex:1];
    if ([cString length] != 6)
        return [UIColor clearColor];
    
    // Separate into r, g, b substrings
    NSRange range;
    range.location = 0;
    range.length = 2;
    
    //r
    NSString *rString = [cString substringWithRange:range];
    
    //g
    range.location = 2;
    NSString *gString = [cString substringWithRange:range];
    
    //b
    range.location = 4;
    NSString *bString = [cString substringWithRange:range];
    
    // Scan values
    unsigned int r, g, b;
    [[NSScanner scannerWithString:rString] scanHexInt:&r];
    [[NSScanner scannerWithString:gString] scanHexInt:&g];
    [[NSScanner scannerWithString:bString] scanHexInt:&b];
    
    return [UIColor colorWithRed:((float) r / 255.0f) green:((float) g / 255.0f) blue:((float) b / 255.0f) alpha:1.0f];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSString *string = @"你猜";
    for (int i= 0; i<3; i++) {
        string = [string stringByAppendingFormat:@",%@", string];
    }
    UIFont *font  = [UIFont systemFontOfSize:17];
    NSLog(@"===%@",[font familyName]);
    
    
//    阴影的颜色
    self.topView.layer.shadowColor = [UIColor blackColor].CGColor;
    
//    阴影的透明度
    self.topView.layer.shadowOpacity = 0.8f;
    
//    阴影的圆角
    self.topView.layer.shadowRadius = 4.f;
    
//    阴影偏移量
    self.topView.layer.shadowOffset = CGSizeMake(0,4);
    
    
    UIView *colorView = [[UIView alloc] init];
    [colorView setFrame:CGRectMake(20, 80, self.view.frame.size.width - 40, 50)];
    [self.view addSubview:colorView];
    CAGradientLayer *gradient = [CAGradientLayer layer];
    gradient.frame = colorView.bounds;
//    //设置开始和结束位置(设置渐变的方向)
    gradient.startPoint = CGPointMake(0, 0);
    gradient.endPoint = CGPointMake(1, 0);
    gradient.colors = [NSArray arrayWithObjects: (id)[UIColor whiteColor].CGColor, (id)[UIColor redColor].CGColor, nil];
    [colorView.layer addSublayer:gradient];
    
   
//   改变不同APP的显示
#if WeChatAPP
    self.topView.backgroundColor = [self colorWithHexString:@"#ff9900"];
#elif TESTAPP
    self.topView.backgroundColor = [UIColor redColor];
#endif

    
    // Do any additional setup after loading the view, typically from a nib.''
}


- (CAShapeLayer *)getProgressView{
    CAShapeLayer *layer = [CAShapeLayer layer];
    
    
    UIBezierPath *path = [UIBezierPath bezierPath];
    // 添加路径[1条点(100,100)到点(200,100)的线段]到path
    [path moveToPoint:CGPointMake(100 , 100)];
    [path addLineToPoint:CGPointMake(200, 100)];
    [path stroke];
    
    
    layer.path = path.CGPath;
    layer.fillColor = [UIColor clearColor].CGColor;
    layer.backgroundColor = [UIColor clearColor].CGColor;
    layer.strokeColor = [UIColor grayColor].CGColor;
    layer.lineWidth = 20;
    layer.lineCap = @"round";
    
    return layer;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
